var mainGridRole;
var mainGridUser;
var mainGridNoticeHost;
var mainGridOrganization;
var mainGridConditions;
var mainGridNoticeRole;
var mainGridNoticeUser;
/*加载单任务节点信息*/
function loadUserTasks(){

    if(sessionStorage.getItem('userTaskJson') == "null" || sessionStorage.getItem('userTaskJson') == "undefined"){return;}
    var properties = JSON.parse(sessionStorage.getItem('userTaskJson'));
    //下个节点
    var nextNodeId = properties["nextNodeId"];
    if(nodeObj[nextNodeId]){
        var nextNodeName = nodeObj[nextNodeId].name;
        $("#node").val(nextNodeId);
        var count=$("#node option").length;
        for(var i=0;i<count;i++)
        {
            if($("#node").get(0).options[i].text == nextNodeName) {
                $("#node").get(0).options[i].selected = true;
                break;
            }
        }
    }

    //执行方法
    var functionId = properties['functionId'];
    if(functionId){
        $.ajax({
            url:path+'/flow/function/getFunctionById?functionId='+functionId,
            type:'post',
            dataType:'json',
            data:{functionId:functionId},
            success:function(func){
                $("#functionName").ligerComboBox().setText(func.functionName);
                $("#functionId").val(functionId);
            }
        });
    }


    //页面
    var editPageId = properties['editPageId'];
    var viewPageId = properties['viewPageId'];
    if(viewPageId){
        $.ajax({
            url:path+'/flow/workPage/getPageNameById',
            type:'post',
            dataType:'json',
            data:{editPageId:editPageId,viewPageId:viewPageId},
            success:function(page){
                $("#viewPageName").ligerComboBox().setText(page.viewPageName);
                $("#viewPageId").val(viewPageId);
            }
        });
    }
    if(editPageId){
        $.ajax({
            url:path+'/flow/workPage/getPageNameById',
            type:'post',
            dataType:'json',
            data:{editPageId:editPageId,viewPageId:viewPageId},
            success:function(page){
                $("#editPageName").ligerComboBox().setText(page.editPageName);
                $("#editPageId").val(editPageId);
            }
        });
    }


    var allowStop = properties['allowStop'];
    var allowRecall = properties['allowRecall'];
    var allowHang = properties['allowHang'];
    if(allowStop == 1){
        $("#allowStop").attr("checked",true);
    }
    if(allowRecall == 1){
        $("#allowRecall").attr("checked",true);
    }
    if(allowHang == 1){
        $("#allowHang").attr("checked",true);
    }
    var notices = properties['notices'];
    var radioId = properties['radioId'];
    var fkId = properties['fkId'];
    var fkIds = [];
    if(fkId != ""){
    	 fkIds = fkId.split(",");
    }
   
    //绑定执行人
    if(fkId != ""){

        $("#"+radioId).click();
        if(radioId == "role"){//角色
            $("#role").attr("checked",true);
            for(var i=0;i<fkIds.length;i++){
                $.ajax({
                    url:path+"/bap/featureRole/getFeturePoleByCode",
                    type:"post",
                    dataType:"json",
                    data:{code:fkIds[i]},
                    success:function(model){
                        var manager = $("#mainGridRole").ligerGetGridManager();
                        var firstRow = manager.getRow(0);
                        manager.addRow({
                            id:model.role_id,
                            roleName:model.role_name,
                            roleCode:model.role_id
                        }, firstRow, true);
                    }
                });
            }
        } else if(radioId == "organizational"){//组织机构
            $("#organizational").attr("checked",true);
            for(var i=0;i<fkIds.length;i++){
                $.ajax({
                    url:path+"/bap/organization/getOrganizationByCode",
                    type:"post",
                    dataType:"json",
                    data:{code:fkIds[i]},
                    success:function(model){
                        var manager = $("#mainGridOrganization").ligerGetGridManager();
                        var firstRow = manager.getRow(0);
                        manager.addRow({
                            id:model.nodeId,
                            organizationName:model.nodeName,
                            organizationCode:model.nodeId
                        }, firstRow, true);
                    }
                });
            }
        } else if(radioId == "executive"){//自定义接收人
            $("#executive").attr("checked",true);
            for(var i=0;i<fkIds.length;i++){
                $.ajax({
                    url:path+"/bap/user/getUserAccount",
                    type:"post",
                    dataType:"json",
                    data:{account:fkIds[i]},
                    success:function(model){
                        var manager = $("#mainGridUser").ligerGetGridManager();
                        var firstRow = manager.getRow(0);
                        manager.addRow({
                            id:model.account,
                            account:model.account,
                            userName:model.userName,
                            userType:model.userName
                        }, firstRow, true);
                    }
                });
            }
        }else if(radioId == "promoter"){//流程发起人
            $("#promoter").attr("checked",true);
        }
    }
    //读取 条件信息
    var conditions = properties["conditions"];
    for(var key in conditions){
        var nextNode = nodeObj[conditions[key]].name;
        var manager = $("#mainGridConditions").ligerGetGridManager();
        var firstRow = manager.getRow(0);
        if(key !="default"){
            manager.addRow({
                id:conditions[key],
                conditions:key,
                nextNode:nextNode
            }, firstRow, true);
        }
    }

}
/*加载通知*/
function loadNotice(){
    if(sessionStorage.getItem('userTaskJson') == "null" || sessionStorage.getItem('userTaskJson') == "undefined"){
        return;
    }
    var properties = JSON.parse(sessionStorage.getItem('userTaskJson'));
    var notices = properties["notices"];
    if(notices){
        var radioId = notices[0].radioId;
        var title = notices[0].title;
        var content = notices[0].content;
        var fkId = notices[0].fkId;
        var fkIds = fkId.split(",");
        $("#"+radioId).click();
        if(radioId =="noticeRole"){
            $("#noticeRoleTitle").val(title);
            $("#noticeRoleContent").val(content);
            for(var i=0;i<fkIds.length;i++){
                $.ajax({
                    url:path+"/bap/featureRole/getFeturePoleByCode",
                    type:"post",
                    dataType:"json",
                    data:{code:fkIds[i]},
                    success:function(model){
                        var manager = $("#mainGridNoticeRole").ligerGetGridManager();
                        var firstRow = manager.getRow(0);
                        manager.addRow({
                        	id:model.role_id,
                            roleName:model.role_name,
                            roleCode:model.role_id
                        }, firstRow, true);
                    }
                });
            }
        }else if(radioId =="noticeExecutive"){
            $("#noticeUserTitle").val(title);
            $("#noticeUserContent").val(content);
            for(var i=0;i<fkIds.length;i++){
                $.ajax({
                    url:"${_ctx}/bap/user/getUserAccount",
                    type:"post",
                    dataType:"json",
                    data:{account:fkIds[i]},
                    success:function(model){
                        var manager = $("#mainGridNoticeUser").ligerGetGridManager();
                        var firstRow = manager.getRow(0);
                        manager.addRow({
                        	id:model.account,
                            account:model.account,
                            userName:model.userName,
                            userType:model.userName
                        }, firstRow, true);
                    }
                });
            }
        }else if(radioId =="noticePromoter"){
            $("#noticeTitle").val(title);
            $("#noticeContent").val(content);
        }
    }

}

var nodeStr = sessionStorage.getItem("nodeStr");
var nodeObj = JSON.parse(nodeStr);
/*创建通知 json对像*/
var isNoticesNull
function noticesJson(){
    isNoticesNull = true;
    var str = "";
    var fkType = "";
    var radioId = "";
    var radios = $("input[name=notice]");
    for(var i=0;i<radios.length;i++){
        if(radios[i].checked){
            fkType = radios[i].value;
            radioId = radios[i].id;
        }
    }
    var noticeJson =[];
    if($("#noticeRole").get(0).checked){//角色
        var manager = $("#mainGridNoticeRole").ligerGetGridManager();
        var rows = manager.getData();
        var roles = [];
        $(rows).each(function () {
            roles.push(this.roleCode);
        });
        str = roles.join(",");
        if((str == "" && $("#noticeRoleTitle").val()=="" && $("#noticeRoleContent").val() == "") || (str != "" && $("#noticeRoleTitle").val()!="" && $("#noticeRoleContent").val() != "")){
            noticeJson = [{radioId:radioId,fkId:str,fkType:fkType,noticeWay:$("#noticeRoleWay").val(),
                title:$("#noticeRoleTitle").val(),content:$("#noticeRoleContent").val()}];
        }else if($("#noticeRoleTitle").val()==""){
            isNoticesNull = false;
            $.ligerDialog.warn("通知标题不能为空")
        }else if($("#noticeRoleContent").val()==""){
            isNoticesNull = false;
            $.ligerDialog.warn("通知内容不能为空")
        }else if(str==""){
            isNoticesNull = false;
            $.ligerDialog.warn("请选择通知接收人")
        }
    }else if($("#noticeExecutive").get(0).checked){//自定义执行人
        var manager = $("#mainGridNoticeUser").ligerGetGridManager();
        var rows = manager.getData();
        var roles = [];
        $(rows).each(function () {
            roles.push(this.account);
        });
        str = roles.join(",");
        if((str == "" && $("#noticeUserTitle").val()=="" && $("#noticeUserContent").val() == "") || (str != "" && $("#noticeUserTitle").val()!="" && $("#noticeUserContent").val() != "")){
            noticeJson = [{radioId:radioId,fkId:str,fkType:fkType,noticeWay:$("#noticeUserWay").val(),
                title:$("#noticeUserTitle").val(),content:$("#noticeUserContent").val()}];
        }else if($("#noticeUserTitle").val()==""){
            isNoticesNull = false;
            $.ligerDialog.warn("通知标题不能为空")
        }else if($("#noticeUserContent").val()==""){
            isNoticesNull = false;
            $.ligerDialog.warn("通知内容不能为空")
        }else if(str==""){
            isNoticesNull = false;
            $.ligerDialog.warn("请选择通知接收人")
        }
    }else if($("#noticePromoter").get(0).checked){//流程发起人
        if(($("#noticeTitle").val()=="" && $("#noticeContent").val() == "") || ($("#noticeTitle").val()!="" && $("#noticeContent").val() != "")){
            noticeJson = [{radioId:radioId,fkId:'${currentUser}',fkType:fkType,noticeWay:$("#noticeWay").val(),
                title:$("#noticeTitle").val(),content:$("#noticeContent").val()}];
        }else if($("#noticeTitle").val()==""){
            isNoticesNull = false;
            $.ligerDialog.warn("通知标题不能为空")
        }else if($("#noticeContent").val()==""){
            isNoticesNull = false;
            $.ligerDialog.warn("通知内容不能为空")
        }
    }
    /*判断： 把没有值的属性删除*/
    for(var k in noticeJson[0]){
        if(noticeJson[0][k]==undefined || noticeJson[0][k] == "" || noticeJson[0][k] == null){
            noticeJson = "";
            break;
        }
    }
    return noticeJson;
}

/*创建条件表达式 JSON 对象*/
function createExpressJson(){

    var conditions = {"default":$("#node").val()};
    var manager = $("#mainGridConditions").ligerGetGridManager();
    var rows = manager.getData();
    $(rows).each(function () {
        conditions[this.conditions] = this.id;
    });
    return conditions;
}

/*创建单个节点的json对象*/
function createJson(){
    var allowStop = 0;
    var allowRecall = 0;
    var allowHang = 0;
    if($("#allowStop").get(0).checked){
      allowStop = 1;
    }
    if($("#allowRecall").get(0).checked){
      allowRecall = 1;
    }
    if($("#allowHang").get(0).checked){
      allowHang = 1;
    }
    var fkType="";
    var radioId = "";
    var radios = $("input[name=fkType]");
    for(var i=0;i<radios.length;i++){
        if(radios[i].checked){
            fkType = radios[i].value;
            radioId = radios[i].id;
        }
    }
    //定义json对象的模型，并赋值
    var ret = {radioId:radioId,type:nodeObj[currentNodeId].type,fkId:fkId(),fkType:fkType,nextNodeId:$("#node").val(), allowStop:allowStop, allowRecall:allowRecall,
        allowHang:allowHang, functionId:$("#functionId").val(),editPageId:$("#editPageId").val(),viewPageId:$("#viewPageId").val(),
        notices:noticesJson(),conditions:createExpressJson()};
    /*判断： 把没有值的属性删除*/
    for(var k in ret){
      if(ret[k]==undefined || ret[k] == "" || ret[k] == null ||JSON.stringify(ret[k]) == "{}"){
          delete ret[k];
      }
    }
    return ret;
  }

/*流程的执行人code*/
function fkId(){
    var str = "";
   if($("#role").get(0).checked){//角色
        var manager = $("#mainGridRole").ligerGetGridManager();
        var rows = manager.getData();
        var roles = [];
        $(rows).each(function () {
            roles.push(this.id);
        });
        str = roles.join(",");
    }else if($("#organizational").get(0).checked){//组织机构
        var manager = $("#mainGridOrganization").ligerGetGridManager();
        var rows = manager.getData();
        var roles = [];
        $(rows).each(function () {
            roles.push(this.id);
        });
        str = roles.join(",");
    }else if($("#executive").get(0).checked){//自定义执行人
        var manager = $("#mainGridUser").ligerGetGridManager();
        var rows = manager.getData();
        var roles = [];
        $(rows).each(function () {
            roles.push(this.id);
        });
        str = roles.join(",");
    }else if($("#promoter").get(0).checked){//流程发起人
        str = '${currentUser}';
    }
    return str;
}

/**
*添加执行角色
 */
function f_addRloe() {
    $.ligerDialog.open({title: "选择角色", width: 450,height:450, allowClose: false, url: path+'/html/flowpages/featureList.jsp',
        buttons: [
            { text: '确定', onclick: function (item, dialog) {
                var roles = dialog.frame.f_roleJson();
                for(var i=0;i<roles.length;i++){
                    var data = mainGridRole.getData();
                    var isOk = true;
                    $(data).each(function () {
                        if(this.roleCode == roles[i].code){
                            isOk = false;
                        }
                    });
                    if(isOk){
                        mainGridRole.addRow({
		            		roleCode:roles[i].id,
		            		id:roles[i].id,
		            		roleName:roles[i].name
		            	});
                    }
                }

                dialog.close();
            }
            },
            { text: '关闭', onclick: function (item, dialog) {
                dialog.close();
            }
            }
        ]
    });
}
/*删除执行角色*/
function f_deleteRole(){
    var manager = $("#mainGridRole").ligerGetGridManager();
    manager.deleteSelectedRow();
}

/**
 *添加通知接收角色
 */
function f_addNoticeRloe() {
    $.ligerDialog.open({title: "选择角色", width: 450,height:450, allowClose: false, url: path+'/html/flowpages/featureList.jsp',
        buttons: [
            { text: '确定', onclick: function (item, dialog) {
                var roles = dialog.frame.f_roleJson();
                for(var i=0;i<roles.length;i++){
                    var data = mainGridNoticeRole.getData();
                    var isOk = true;
                    $(data).each(function () {
                        if(this.roleCode == roles[i].id){
                            isOk = false;
                        }
                    });
                    if(isOk){
                    	mainGridNoticeRole.addRow({
                            id:roles[i].id,
                            roleName:roles[i].name,
                            roleCode:roles[i].id
                        });
                    }
                }

                dialog.close();
            }
            },
            { text: '关闭', onclick: function (item, dialog) {
                dialog.close();
            }
            }
        ]
    });
}
/*删除通知接收角色*/
function f_deleteNoticeRole(){
    var manager = $("#mainGridNoticeRole").ligerGetGridManager();
    manager.deleteSelectedRow();
}

/**
 *组织机构
 */
function f_addOrganization() {
    $.ligerDialog.open({title: "选择组织机构", width: 450,height:450, allowClose: false, url: path+'/html/flowpages/flow_OrganizationList.jsp',
        buttons: [
            { text: '确定', onclick: function (item, dialog) {
                var organizations = dialog.frame.f_organizationJson();
                for(var i=0;i<organizations.length;i++){
                    var data = mainGridOrganization.getData();
                    var isOk = true;
                    $(data).each(function () {
                        if(this.id == organizations[i].id){
                            isOk = false;
                        }
                    });
                    if(isOk){
                    	mainGridOrganization.addRow({
                            id:organizations[i].id,
                            organizationName:organizations[i].name,
                            organizationCode:organizations[i].id
                        });
                    }
                }
                dialog.close();
            }
            },
            { text: '关闭', onclick: function (item, dialog) {
                dialog.close();
            }
            }
        ]
    });
}
/*删除机构*/
function f_deleteOrganization(){
    var manager = $("#mainGridOrganization").ligerGetGridManager();
    manager.deleteSelectedRow();
}

/*添加流程执行人*/
function f_addUser() {
    $.ligerDialog.open( {width: 450,height:450, allowClose: false, url: path+'/html/flowpages/flow_userList.jsp',
        buttons: [
            { text: '确定', onclick: function (item, dialog) {
                var users = dialog.frame.f_userJson();
                for(var i=0;i<users.length;i++){
                    var manager = $("#mainGridUser").ligerGetGridManager();
                    var firstRow = manager.getRow(0);
                    var data = mainGridUser.getData();
                    var isOk = true;
                    $(data).each(function () {
                        if(this.account == users[i].account){
                            isOk = false;
                        }
                    });
                    if(isOk){
                    	mainGridUser.addRow({
                            id:users[i].id,
                            account:users[i].account,
                            userName:users[i].userName,
                            userType:users[i].userType
                        });
                    }
                }
                dialog.close();
            }
            },
            { text: '关闭', onclick: function (item, dialog) {
                dialog.close();
            }
            }
        ]
    });
}
/*删除流程执行人*/
function f_deleteUser(){
    var manager = $("#mainGridUser").ligerGetGridManager();
    manager.deleteSelectedRow();
}

/*添加通知接收人*/
function f_addNoticeUser() {
    $.ligerDialog.open( {width: 450,height:450, allowClose: false, url: path+'/html/flowpages/flow_userList.jsp',
        buttons: [
            { text: '确定', onclick: function (item, dialog) {
                var users = dialog.frame.f_userJson();
                for(var i=0;i<users.length;i++){
                    var manager = $("#mainGridNoticeUser").ligerGetGridManager();
                    var firstRow = manager.getRow(0);
                    var data = manager.getData();
                    var isOk = true;
                    $(data).each(function () {
                        if(this.id == users[i].id){
                            isOk = false;
                        }
                    });
                    if(isOk){
                        manager.addRow({
                            id:users[i].account,
                            account:users[i].account,
                            userName:users[i].userName,
                            userType:users[i].userType
                        }, firstRow, true);
                    }
                }
                dialog.close();
            }
            },
            { text: '关闭', onclick: function (item, dialog) {
                dialog.close();
            }
            }
        ]
    });
}
/*删除通知接收人*/
function f_deleteNoticeUser(){
    var manager = $("#mainGridNoticeUser").ligerGetGridManager();
    manager.deleteSelectedRow();
}

/*条件控制弹窗*/
function conditionsDialog(){
    $.ligerDialog.open({title:'条件设置',width: 550,height:400, allowClose: false, url: path+'/flow/processParameter/conditions?processId='+processId,
        buttons: [
            { text: '确定', onclick: function (item, dialog) {
                var express = dialog.frame.getExpress();
                if(dialog.frame.isEmpty =="next"){
                    BAP.show("请输入下步节点");
                }else if(dialog.frame.isEmpty =="express"){
                    BAP.show("请输入条件表达式");
                }else{
                    var manager = $("#mainGridConditions").ligerGetGridManager();
                    var firstRow = manager.getRow(0);
                    manager.addRow({
                        id:express.nodeValue,
                        conditions:express.express,
                        nextNode:express.nextNode
                    }, firstRow, true);
                    dialog.close();
                }
            }
            },
            { text: '关闭', onclick: function (item, dialog) {
                dialog.close();
            }
            }
        ]
    });
}
/*删除条件*/
function f_deleteExpress(){
    var manager = $("#mainGridConditions").ligerGetGridManager();
    manager.deleteSelectedRow();
}
/*获取下个节点的id*/
function nextNodeId(){
    var nextNodes = [];
    var nodeId = $("#node").val();
    var manager = $("#mainGridConditions").ligerGetGridManager();
    var data = manager.getData();
    $(data).each(function () {
        nextNodes.push(this.id);
    });
    nextNodes.push(nodeId);
    return nextNodes;
}
$(function(){
    $("textarea").css({"min-width":"550px","min-height":"100px","max-width":"550px","max-height":"100px"});
    $("input[type=button]").css({"background":"#ffffff","display":"inline-block","cursor":"pointer"});
    /*绑定方法下拉框*/
    $("#functionName").ligerComboBox({
        url: path+'/flow/function/getComboBoxData?processId='+processId,
        valueField: 'id',
        textField: 'functionName',
        valueFieldID: 'functionId',
        selectBoxWidth: 170,
        width: 170,
        highLight:true,
        cancelable:true
    });

    /*绑定编辑页面下拉框*/
    $("#editPageName").ligerComboBox({
        url:path+'/flow/workPage/getComboBoxData?processId='+processId+'&type=2',
        valueField: 'id',
        textField: 'pageName',
        valueFieldID: 'editPageId',
        selectBoxWidth: 170,
        width: 170,
        highLight:true,
        cancelable:true
    });
    /*绑定查看页面下拉框*/
    $("#viewPageName").ligerComboBox({
        url:path+'/flow/workPage/getComboBoxData?processId='+processId+'&type=1',
        valueField: 'id',
        textField: 'pageName',
        valueFieldID: 'viewPageId',
        selectBoxWidth: 170,
        width: 170,
        highLight:true,
        cancelable:true
    });
    /*执行岗位列表*/
    $("#mainGrid").ligerGrid({
        columns: [
            { display: 'id', name: 'id', hide: true, width: 60 },
            { display: '序号', width: 40, render: function (rowData, rowindex, value, column, rowid, page, pagesize) { return (page - 1) * pagesize + rowindex + 1; } },
            { display: '岗位名称', name: 'hostName', align: 'center', width: 160 },
            { display: '岗位代码', name: 'hostCode', align: 'center', width: 140 },
            { display: '组织机构', name: 'organization', align: 'center', width: 140 }
        ],
        width: '100%', heightDiff: -1,height:'50%',
        usePager:false,
        checkbox:true,
        onSelectRow:function(data){

        }
    });
    /*接收通知岗位列表*/
    mainGridNoticeHost = $("#mainGridNoticeHost").ligerGrid({
        columns: [
            { display: 'id', name: 'id', hide: true, width: 60 },
            { display: '序号', width: 40, render: function (rowData, rowindex, value, column, rowid, page, pagesize) { return (page - 1) * pagesize + rowindex + 1; } },
            { display: '岗位名称', name: 'hostName', align: 'center', width: 160 },
            { display: '岗位代码', name: 'hostCode', align: 'center', width: 140 },
            { display: '组织机构', name: 'organization', align: 'center', width: 140 }
        ],
        width: '100%', heightDiff: -1,height:'50%',
        usePager:false
    });

    /*条件控制*/
    mainGridConditions = $("#mainGridConditions").ligerGrid({
        columns: [
            { display: 'id', name: 'id', hide: true, width: 60 },
            { display: '序号', width: 40, render: function (rowData, rowindex, value, column, rowid, page, pagesize) { return (page - 1) * pagesize + rowindex + 1; } },
            { display: '条件表达式', name: 'conditions', align: 'center',width:200},
            { display: '下部步节点', name: 'nextNode', align: 'center',width:200}
        ],
        width: '100%', heightDiff: -1,height:'50%', usePager:false, checkbox:true
    });

    /*接收通知角色列表*/
    mainGridNoticeRole = $("#mainGridNoticeRole").ligerGrid({
        columns: [
            { display: 'id', name: 'id', hide: true, width: 60 },
            { display: '角色名称', name: 'roleName', align: 'center', width: 200 },
            { display: '角色代码', name: 'id', align: 'center', width: 200 },
        ],
        width: '100%',
    });
    /*执行角色列表*/
    mainGridRole = $("#mainGridRole").ligerGrid({
        columns: [
            { display: 'id', name: 'id', hide: true, width: 60 },
            { display: '角色名称1', name: 'roleName', align: 'center', width: 200 },
            { display: '角色代码', name: 'roleCode', align: 'center', width: 200 },
        ],
        width: '100%',
    });

    /*组织机构*/
    mainGridOrganization = $("#mainGridOrganization").ligerGrid({
        columns: [
            { display: 'id', name: 'id', hide: true, width: 60 },
            { display: '序号', width: 40, render: function (rowData, rowindex, value, column, rowid, page, pagesize) { return (page - 1) * pagesize + rowindex + 1; } },
            { display: '机构名称', name: 'organizationName', align: 'center', width: 200 },
            { display: '机构代码', name: 'organizationCode', align: 'center', width: 200 },
        ],
        width: '100%',
    });

    /*自定义执行人*/
    mainGridUser = $("#mainGridUser").ligerGrid({
        columns: [
            { display: 'id', name: 'id', hide: true, width: 60 },
            //{ display: '序号', width: 40, render: function (rowData, rowindex, value, column, rowid, page, pagesize) { return (page - 1) * pagesize + rowindex + 1; } },
            { display: '帐号', name: 'account', align: 'center',width:100},
            { display: '名称', name: 'userName', align: 'center',width:100},
            { display: '类型', name: 'userType', align: 'center',width:60, render: function (row) {return 'employee' == row['userType'] ? '内部员工' : '合作伙伴'}},
        ],
        width: '100%',
    });
    /*接收通知人列表*/
    mainGridNoticeUser = $("#mainGridNoticeUser").ligerGrid({
        columns: [
            { display: 'id', name: 'id', hide: true, width: 60 },
            { display: '序号', width: 40, render: function (rowData, rowindex, value, column, rowid, page, pagesize) { return (page - 1) * pagesize + rowindex + 1; } },
            { display: '帐号', name: 'account', align: 'center',width:100},
            { display: '名称', name: 'userName', align: 'center',width:100},
            { display: '类型', name: 'userType', align: 'center',width:60, render: function (row) {return 'employee' == row['userType'] ? '内部员工' : '合作伙伴'}},
        ],
        width: '100%', heightDiff: -1,height:'50%',
        usePager:false
    });

    /*
     *接收并初始化节点
     */
    $("#currentNodeName").val(nodeObj[currentNodeId].name);
    for(var node in nodeObj){
        var nodeChild = nodeObj[node];
        if(nodeChild.type != "start round" && node != currentNodeId){
            $("#node").append("<option value='"+node+"'>"+nodeChild.name+"</option>");
        }
    }
    $("#navtab1").ligerTab();

    /*任务执行人单选按钮的切换*/
    $("input[name=fkType]").click(function(){
        $(".post:eq("+$(this).index()+")").show().siblings().hide();
    });
    /*通知接收人单选按钮的切换*/
    $("input[name=notice]").click(function(){
        $(".notice:eq("+$(this).index()+")").show().siblings().hide();
    });

    /*调用加载单任务的方法*/
    loadUserTasks();
    loadNotice();
});

    